load input/cmap8OMs.mat   % color map

train1 = diff([0 train(1,:)]);
trainIdx = find(train1~=0);

test1 = diff([0 test(1,:)]);
testIdx = find(test1~=0);

figure;
for i = 1:8
   subplot 211; hold on; plot(OM(i,:)+OM(i+8,:)+OM(i+16,:),'color',cmap(i,:)/255); axis tight; title('EEG = P+E+I');
end 
set(gca,'XTickLabel',{1:9},'XTick',1:9);
set(gca,'XTickLabel',{1:9},'XTick',10000:10000:90000);
xlabel('Time (s)')
title('Activity')

subplot 212;hold on;  plot(train,'r'); axis tight; 
subplot 212;hold on;  plot(test,'b'); axis tight; 
set(gca,'XTickLabel',{1:9},'XTick',1:9);
set(gca,'XTickLabel',{1:9},'XTick',10000:10000:90000);
xlabel('Time (s)')
title('Trigger signals')
legend({'Training','Test'})

figure;
subplot 121; 
OM1 = OM(:,trainIdx(1):trainIdx(2));
OM2 = OM(:,testIdx(3)+1500:testIdx(3)+11500);
for i = 1:8
   subplot 121; hold on; plot(OM1(i,:)+OM1(i+8,:)+OM1(i+16,:),'color',cmap(i,:)/255); axis tight; title('EEG = P+E+I');
   subplot 122; hold on; plot(OM2(i,:)+OM2(i+8,:)+OM2(i+16,:),'color',cmap(i,:)/255); axis tight; title('EEG = P+E+I');
end 
legend({'0','22.5','45','67.5','90','112.5','145','157.5'});



